package com.shanghaionstar.nav.adapter;

import android.content.Context;
import android.widget.TextView;

import com.onstar.cn.common.util.CommonUtil;
import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonAdapter;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.onstar.cn.sqlite.entities.RouteHistory;
import com.shanghaionstar.R;

import java.util.List;

public class PoiRouteHistoryListAdapter extends CommonAdapter<RouteHistory> {
	private Context mContext;
	private List<RouteHistory> mItemList;
	private int poiLength;
	
	public PoiRouteHistoryListAdapter(List<RouteHistory> datas, Context context, int length) {
		super(datas, context);
		mContext = context;
		mItemList = datas;
		poiLength = length;
	}

	
	@Override
	public void getView(int position, CommonViewHolder viewHolder) {
		ViewHolder holder = (ViewHolder) viewHolder;
		String title = mItemList.get(position).getStartPoiName() + "(" + mItemList.get(position).getStartPoiAdress() + ")";
		if(!CommonUtil.isNull(title)){
			holder.poi_title_text_id.setText(title);
		}else{
			holder.poi_title_text_id.setText("----");
		}
		String address = mItemList.get(position).getEndPoiName() + "(" + mItemList.get(position).getEndPoiAdress() + ")";
		if(!CommonUtil.isNull(address)){
			holder.poi_address_text_id.setText(address);
		}else{
			holder.poi_address_text_id.setText("----");
		}
	}

	
	@Override
	public int layoutId() {
		return R.layout.nav_poi_search_page_item;
	}

	@Override
	public CommonViewHolder getViewHolder() {
		return new ViewHolder();
	}
	private class ViewHolder extends CommonViewHolder {
		@FindViewById
		TextView poi_title_text_id,poi_address_text_id;
	}
}
